/**
 * Created by Administrator on 2018/11/13 0013.
 */
//用户登录
function userLogin(username,password) {
    //验证签名
    sign.params = {
        username:username,
        password:password
    }
    var encode_data = sign.encode_post();

    $.post(url_list.login,encode_data,function (data) {
        //解码
        if(typeof data == 'string'){
            data = JSON.parse(data);
        }
        data = sign.decode_post(data);
        console.log(data);
        //返回数组
        if(data.code == "200")
            $("#lg-form").slideUp('slow', function(){
                location.href = url_list.home;
            });
        else{
            layui.use(['layer', 'form'], function() {
                layer.msg(data.msg, {icon: 2}, 1500);
            })
        }
    },'json')
}

//用户注册
function userRegister(username,password,password_confirm,phone) {
    //验证签名
    sign.params = {
        username:username,
        password:password,
        password_confirm:password_confirm,
        phone:phone
    };
    var encode_data = sign.encode_post();

    $.post(url_list.user_register,encode_data,function (data) {
        //解码
        if(typeof data == 'string'){
            data = JSON.parse(data);
        }
        data = sign.decode_post(data);
        console.log(data);
        //返回数组
        layui.use(['layer', 'form'], function() {
            if(data.code == "200"){
                layer.msg(data.msg,{icon:1});
                location.href = url_list.user_index;
            }
            else{
                layer.msg(data.msg,{icon:2});
            }
        })
    },'json')
}